package com.wxapp.sale.service.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import com.wxapp.sale.api.pojo.vm.goodsBrand.PGoodsBrandDetailVm;
import com.wxapp.sale.api.pojo.vm.goodsBrand.PGoodsBrandPageVm;
import com.wxapp.sale.api.pojo.vm.goodsBrand.PGoodsBrandSelectVm;
import com.wxapp.sale.api.pojo.vo.goodsBrand.QGoodsBrandAddVo;
import com.wxapp.sale.api.pojo.vo.goodsBrand.QGoodsBrandPageVo;
import com.wxapp.sale.api.pojo.vo.goodsBrand.QGoodsBrandUpdateVo;
import com.wxapp.sale.service.service.GoodsBrandService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 * @Description 商品品牌管理
 * @Datetime 2023/4/23 15:58
 * @Modified By
 */
@RestController
@RequestMapping("goods/brand")
@Tag(name = "商品品牌管理")
@RequiredArgsConstructor
public class GoodsBrandController extends IBaseController {
    private final GoodsBrandService goodsBrandService;

    @PostMapping("add")
    @Operation(summary ="添加商品品牌")
    public ResultVm<String> add(@Schema(hidden = true) @User UserVo userVo, @RequestBody QGoodsBrandAddVo qGoodsBrandAddVo) {
        return goodsBrandService.add(userVo, qGoodsBrandAddVo);
    }

    @PutMapping("update")
    @Operation(summary ="更新商品品牌")
    public ResultVm<String> update(@Schema(hidden = true) @User UserVo userVo, @RequestBody QGoodsBrandUpdateVo qGoodsBrandUpdateVo) {
        return goodsBrandService.update(userVo, qGoodsBrandUpdateVo);
    }

    @DeleteMapping("delete/{id}")
    @Operation(summary ="删除商品品牌")
    public ResultVm<String> delete(@Schema(hidden = true) @User UserVo userVo, @PathVariable String id) {
        return goodsBrandService.delete(userVo, id);
    }

    @GetMapping("detail/{id}")
    @Operation(summary ="商品品牌详情")
    public ResultVm<PGoodsBrandDetailVm> detail(@PathVariable String id) {
        return goodsBrandService.detail(id);
    }

    @PostMapping("page")
    @Operation(summary ="获取商品类型")
    public ResultVm<Page<PGoodsBrandPageVm>> page(@RequestBody QGoodsBrandPageVo qListVo, @Schema(hidden = true) @User UserVo userVo) {
        return goodsBrandService.page(qListVo,userVo);
    }

    @GetMapping("select")
    @Operation(summary ="获取商品类型下拉框")
    public ResultVm<List<PGoodsBrandSelectVm>> select(@RequestParam(value = "name", required = false) String name, @Schema(hidden = true) @User UserVo userVo) {
        return goodsBrandService.select(name,userVo);
    }
}
